package logic

import (
	"context"
	"rent-ease/models/mysql"

	"rent-ease/rentrpc/internal/svc"
	"rent-ease/rentrpc/rentrpc"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewHouseDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseDetailLogic {
	return &HouseDetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 详情
func (l *HouseDetailLogic) HouseDetail(in *rentrpc.HouseDetailRequest) (*rentrpc.HouseDetailResponse, error) {
	// todo: add your logic here and delete this line
	var house mysql.House
	err := house.HouseDetail(mysql.DB, in.HouseId)
	if err != nil {
		return nil, err
	}
	return &rentrpc.HouseDetailResponse{
		HouseId:      int64(house.ID),
		HouseName:    house.HouseName,
		HouseAddress: house.HouseAddress,
		HousePrice:   house.HousePrice,
	}, nil
}
